//
//  ZJAddressManageCell.m
//  ZiJinLian
//
//  Created by lc on 2017/3/22.
//  Copyright © 2017年 lzy. All rights reserved.
//

#import "ZJAddressManageCell.h"

@implementation ZJAddressManageCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        //self.backgroundColor=[UIColor whiteColor];
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        _nameLab=[ZJUITools getLab_S14_C3];
        _phoneLab=[ZJUITools getLab_S14_C3];
        _detailLab=[ZJUITools getLab_S14_C3];
        _setDeafulBtn=[ZJUITools getBtnWithSelect:@"icon_rb_nor" select:@"icon_rb_pre" title:@"默认地址"];
        _editBtn=[ZJUITools getBtnWithImage:@"icon_edit" title:@"编辑"];
        _deleteBtn=[ZJUITools getBtnWithImage:@"icon_delete" title:@"删除"];
        _cutine=[ZJUITools getCutLine];
        _detailLab.numberOfLines=1;
        
        [self addSubview:_nameLab];
        [self addSubview:_phoneLab];
        [self addSubview:_detailLab];
        [self addSubview:_setDeafulBtn];
        [self addSubview:_editBtn];
        [self addSubview:_deleteBtn];
        [self addSubview: _cutine];
        
        [self addConstraint];
        [self doOpeartion];
        
    }
    return self;
}
//添加约束
-(void)addConstraint{
    [_nameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.top.equalTo(self.mas_top).offset(10);


    }];
    
    [_phoneLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.mas_right).offset(-10);
        make.top.equalTo(self.mas_top).offset(10);
    }];
    
    [_detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.top.equalTo(_phoneLab.mas_bottom).offset(10);
    }];
    [_cutine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_detailLab.mas_bottom).offset(10);
        make.left.equalTo(self.mas_left);
        make.width.equalTo(self.mas_width);
        make.height.mas_equalTo(0.5);
    }];
    
    [_setDeafulBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(10);
        make.top.equalTo(_cutine.mas_top).offset(10);

    }];
    [_editBtn mas_makeConstraints:^(MASConstraintMaker *make) {
         make.top.equalTo(_cutine.mas_top).offset(10);
         make.centerX.equalTo(self.mas_centerX);

    }];
    [_deleteBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(_cutine.mas_top).offset(10);
        make.right.equalTo(self.mas_right).offset(-10);

    }];

}
-(void)doOpeartion{
    

}

-(void)setupCell:(ZJAdressModel *)model{
    _nameLab.text=model.consigneeName;
    _phoneLab.text=model.consigneePhone;
    _detailLab.text=[NSString stringWithFormat:@"%@%@",[model.area stringByReplacingOccurrencesOfString:@" " withString:@""],model.detail];
    [_setDeafulBtn setSelected:model.isDefault==1];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
}




@end
